function fetch_ajax(){
    var xhr = new XMLHttpRequest();
    var url_ajax = 'http://localhost:5000/sgin/get' + uri();
    xhr.open('get',url_ajax);
    xhr.send();
    xhr.onload = function () {
        document.getElementById('sgin_id').innerHTML = hex_md5(xhr.responseText)
        console.log(hex_md5(xhr.responseText))
    }
}

function randints(max,n,is_num){
    /*
    max:返回数字范围
      n:返回数字个数
 is_num: 0:返回数字 1：返回字符
    */
    var result=[];
    if(is_num){
        return Math.floor(Math.random()*max);
    }
    for (var i = 0; i < n; i++) {
        s = Math.floor(Math.random()*max)
        result.push(s);
    }
    return result.join('');
}

function randstrs(n) {
    var result = [];
    for (var i = 0; i < n; i++) {
        s = String.fromCharCode(65+randints(25,1,1));
        result.push(s);
    }
    return result.join('')
}

function uri() {
    var action = randints(9,5,0);
    var time_now = new Date().getTime().toString();
    var randstr = randstrs(5);
    var md5hex = hex_md5(action+time_now+randstr);
    var args = '?actions='+action+'&time='+time_now+'&randstr='+randstr+'&sgin='+md5hex;
    return args
}

